// DIBImage.h: interface for the CDIBImage class.
//
//////////////////////////////////////////////////////////////////////
//This is a program special for operation of DIB bitmap
//
#if !defined(AFX_DIBIMAGE_H__FF3BFD01_C05D_11D4_99A4_8A07EFE39746__INCLUDED_)
#define AFX_DIBIMAGE_H__FF3BFD01_C05D_11D4_99A4_8A07EFE39746__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)
#define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top)

class CDIBImage  : public CObject
{
	DECLARE_SERIAL(CDIBImage)

public:
	CDIBImage();
	virtual ~CDIBImage();
public:
	BOOL IsEmpty();
	BOOL Write(CFile &file);	
	BOOL Read(CFile& file);
	BOOL Draw(HDC hDC,LPRECT lpDCRect,LPRECT lpDIBRect);
	int WidthBytes();
	int GetHeight();
	int GetWidth();
	BOOL CreatImagePalette();
	int ComputeColorNum();
	void Empty();
public:
	void MorphDilation(BOOL m_struct[3][3]);
	void MorphErosion(BOOL m_struct[3][3]);
	void Threshold(int thresh);
	void Serialize(CArchive& ar);
	HBITMAP CreateBitmap(CDC *pDC);
	LPBYTE m_lpImage;
	LPBITMAPINFOHEADER m_lpBih;
	CString m_filename;
private:
	LPRGBQUAD m_lpColorTable;
	HPALETTE m_hPal;
};

#endif // !defined(AFX_DIBIMAGE_H__FF3BFD01_C05D_11D4_99A4_8A07EFE39746__INCLUDED_)
